class PrizesController < ApplicationController
  # 用户选择这个奖品
  # 当 prize 的 streak 小于 当前的 streak_count 的时候才允许
  def select
    @prize = Prize.find params[:id]
    if current_user.winstreak.streak_count.to_i >= @prize.streak
      flash[:error] = "You cannot change to this prize."
    else
      current_user.prize = @prize
      current_user.save
      flash[:notice] = "You have selected the #{@prize.name}"
    end
    redirect_to bets_path
  end

end
